home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / src / dd / defs.h < prev    next >
C/C++ Source or Header  |  1994-02-06  |  8KB  |  334 lines

  1. /*
  2.  * Defs.h
  3.  *
  4.  * Synopsis:
  5.  *    Master include file for DBug debugger.
  6.  */
  7. #include    <localdefs.h>
  8.  
  9.  
  10. // * Macros
  11.  
  12. #define arysize(ary)          (sizeof(ary)/sizeof((ary)[0]))
  13.  
  14. // * Data structures
  15.  
  16. typedef struct DLIST {
  17.     NODE    node;
  18.     char    name[2];
  19. } DLIST;
  20.  
  21. // for the sorted symbol list display
  22.  
  23. typedef struct SYMLIST {
  24.     ULONG *symbolname;
  25.     ULONG address;
  26. } SYMLIST;
  27.  
  28. // for menus
  29. #define NM_BAR    4
  30.  
  31. enum DTYPES {
  32.     DTYPE_DOSBASE,
  33.     DTYPE_PROCESS,
  34.     DTYPE_INFO,
  35.     DTYPE_EXECBASE,
  36.     DTYPE_RESOURCES,
  37.     DTYPE_INTRS,
  38.     DTYPE_PORTS,
  39.     DTYPE_TASKS,
  40.     DTYPE_LIBS,
  41.     DTYPE_DEVICES,
  42.     DTYPE_MEMLIST,
  43.     DTYPE_REXXLIST,
  44.     DTYPE_SYMLIST,
  45.     MAX_DTYPE,
  46. };
  47.  
  48. typedef struct DBugDisp {
  49.     NODE    ds_Node;
  50.     WINDOW    *ds_Win;        //  control window
  51.     STDREQ    ds_CReadReq;        //  console read request
  52.     STDREQ    ds_CWriteReq;        //  console write request
  53.  
  54.     UBYTE    ds_CReadIP;        //  read request in progress
  55.     UBYTE    ds_CWriteIP;        //  write request in progress (not used)
  56.     UBYTE    ds_OpenError;
  57.     UBYTE    ds_CsiState;        //  CSI escape state machine
  58.  
  59.     UBYTE    ds_DoneFlag;
  60.     UBYTE    ds_DisplayOffsets;
  61.     UBYTE    ds_PromptLen;
  62.     UBYTE    ds_PromptStart;
  63.  
  64.     ULONG    ds_Flags;
  65.  
  66.  
  67.     UBYTE    ds_CInChar;        //  console buffering
  68.     UBYTE    ds_COutBuf[255];
  69.     WORD    ds_COutIndex;
  70.  
  71.     UWORD    ds_DisplayMode;     //  display mode for window
  72.     UWORD    ds_PreferedMode;    //  prefered mode for window
  73.  
  74.     UWORD    ds_ScrRows;        //  computed window boundries
  75.     UWORD    ds_ScrCols;
  76.  
  77.     UWORD    ds_ScrTop;
  78.     UWORD    ds_ScrColNo;        //  CHARMAP TRACKING / MOUSE BUT
  79.  
  80.     UWORD    ds_ScrRowNo;
  81.  
  82.     UBYTE    ds_RegFlag;        // register display off or on for window
  83.     UBYTE    ds_RegTouched;        // flag for auto registers control
  84.  
  85.     UBYTE    *ds_ScrAry;
  86.  
  87.     //  ds_Window* modes are managed mainly by the up/down/refresh
  88.     //  routines associated with a display mode and do not necessarily
  89.     //  contain addresses
  90.  
  91.     ULONG    ds_WindowTop;        //  top address / index
  92.     ULONG    ds_WindowTopLine;    //  top sub-address / index (mixed mode)
  93.     ULONG    ds_WindowBot;        //  bottom address / index
  94.     ULONG    ds_WindowBotLine;    //  bottom sub-addrss / index (mixed mode)
  95.  
  96.     ULONG    ds_LastRefreshMode;    //  used to determine non-linear
  97.     ULONG    ds_LastRefreshTop;    //  changes and force a full refresh
  98.  
  99.     LIST    ds_List;        // list used for special list display mode
  100.     char    ds_windowTitle[128];
  101. } DBugDisp;
  102.  
  103. #define DF_STACK    0x0001
  104.  
  105.  
  106. // there is an array of these for each -d1 debug LINE hunk
  107. // the addresses are relocated at load time
  108. typedef struct SOURCE {
  109.     ULONG    lineNumber;            // lineNumber of source line
  110.     ULONG    address;            // address of source line in memory
  111. } SOURCE;
  112.  
  113. // For each code/data/bss hunk, there may be a linked list of these DEBUG structures.
  114. // Each DEBUG structure contains source-level debugging information.
  115. typedef struct DEBUG    {
  116.     struct DEBUG    *link;            // ptr to next debug_struct in list
  117.     struct SOURCE    *table;         // ptr to line#/address pair table
  118.     struct SOURCE    *tableEnd;        // ptr to end of line#/address pair table
  119.     char        sourceName[128];    // source filename
  120.     char        *source;        // ptr to source file in RAM
  121.     ULONG        addrBegin;        // range debug hunk applies to
  122.     ULONG        addrEnd;
  123. } DEBUG;
  124.  
  125. // At load time, the HUNK_HEADER hunk determines how many code/data/bss hunks exist for the file.
  126. // An array of that many (numHunks) HUNK structures is allocated.  Each HUNK contains a pointer
  127. // to the actual file data and a pointer to the allocated memory to hold the hunk during runtime.
  128. // When the program is reset, the hunk data is copied to the allocated memory and relocated.
  129. typedef struct HUNK {
  130.     ULONG    type;                // type of hunk (code/data + FAST/CHIP)
  131.     ULONG    size;                // size of allocated hunk (may be larger than hunk_Hsize)
  132.     ULONG    *memptr;             // ptr to actual hunk start
  133.     ULONG    *actual;             // ptr to actual hunk data
  134.     ULONG    hSize;                // size of hunk data, in longs
  135.     APTR    hunk;                // ptr to hunk in file
  136.     APTR    reloc32;            // ptr to reloc32 hunk in file
  137.     APTR    symbols;            // ptr to symbol hunk in file
  138.     DEBUG    *debug;             // ptr to debug_struct list for this hunk
  139. } HUNK;
  140.  
  141. // Breakpoint table format
  142. typedef struct BP {
  143.     UWORD    state;                // see defines below
  144.     UWORD    count;                // # times breakpoint hit before halting...
  145.     UWORD    value;                // save wd value from code at bp_Address
  146.     UWORD    *address;            // address of breakpoint
  147. } BP;
  148.  
  149. // There are 3 kinds of breakpoints...
  150. #define BP_UNSET    0            // no breakpoint at all
  151. #define BP_SET        1            // sticky breakpoint
  152. #define BP_GROUP    2            // group breakpoint
  153.  
  154. #define MAXBP        32            // max # of breakpoints
  155.  
  156. // Watchpoint table format
  157. typedef struct WP {
  158.     ULONG        type;            // see defines below
  159.     char        expression[128];    // expression evaluated at display time
  160. } WP;
  161.  
  162. #define MAXWP        32            // max # of watchpoints
  163.  
  164. // There are 4 kinds of watchpoints...
  165. #define WP_UNSET    0
  166. #define WP_BYTES    1
  167. #define WP_WORDS    2
  168. #define WP_LONGS    3
  169.  
  170. #define MAXCOMMAND    96
  171.  
  172. // preferences
  173. typedef struct DPREFS    {
  174.     UWORD    top,left,width,height;
  175.     UWORD DefaultMode;
  176.     UBYTE DefaultOffset;
  177.     alias[MAXCOMMAND];
  178. } DPREFS;
  179.  
  180.  
  181. #define REXXPORTNAME    "DD"
  182. #define REXXEXT        "DD"
  183. #define MAX_REXX_REPLY    256
  184.  
  185. // * Global variables
  186.  
  187. extern IBASE            *IntuitionBase;
  188. extern GBASE            *GfxBase;
  189. extern EBASE            *SysBase;
  190. extern struct DosLibrary    *DOSBase;
  191. extern struct Library        *GadToolsBase;
  192.  
  193. extern char *RexxHostName;
  194.  
  195. extern char    *args;
  196. extern ULONG    argSize;
  197. extern TASK    *thisTask;
  198. extern APROCESS *thisProcess;
  199. extern CLI    *thisCli;
  200.  
  201. extern char    targetName[];
  202. extern ULONG    *exeFile;
  203. extern ULONG    exeSize;
  204. extern ULONG    numHunks, firstHunk, lastHunk;
  205. extern HUNK    *hunkArray;
  206.  
  207.  
  208. extern USHORT oldrow, oldcol;
  209.  
  210.     // value of programState
  211. #define STATE_RUNNING            0
  212. #define STATE_HALTED            1
  213. #define STATE_BUS_ERROR         2
  214. #define STATE_ADDRESS_ERROR        3
  215. #define STATE_ILLEGAL_INSTRUCTION    4
  216. #define STATE_ZERO_DIVIDE        5
  217. #define STATE_CHK            6
  218. #define STATE_TRAPV            7
  219. #define STATE_PRIVILEDGE_VIOLATION    8
  220. #define STATE_TRACE            9
  221. #define STATE_LINEA            10
  222. #define STATE_LINEF            11
  223. //                ...    ..
  224. #define STATE_RESET            64
  225. #define STATE_EXITED            65
  226. #define STATE_STEPPED            66
  227. #define STATE_STEPPEDOVER        67
  228. #define STATE_BREAKPOINT        68
  229.  
  230. extern UBYTE    *programStack;
  231. extern ULONG    programStackSize;
  232.  
  233. extern ULONG    programState;
  234. extern UWORD    programSR;
  235. extern ULONG    programPC;
  236. extern ULONG    programD0;
  237. extern ULONG    programD1;
  238. extern ULONG    programD2;
  239. extern ULONG    programD3;
  240. extern ULONG    programD4;
  241. extern ULONG    programD5;
  242. extern ULONG    programD6;
  243. extern ULONG    programD7;
  244. extern ULONG    programA0;
  245. extern ULONG    programA1;
  246. extern ULONG    programA2;
  247. extern ULONG    programA3;
  248. extern ULONG    programA4;
  249. extern ULONG    programA5;
  250. extern ULONG    programA6;
  251. extern ULONG    programA7;
  252.  
  253. extern ULONG    lastState;
  254. extern UWORD    lastSR;
  255. extern ULONG    lastPC;
  256. extern ULONG    lastD0;
  257. extern ULONG    lastD1;
  258. extern ULONG    lastD2;
  259. extern ULONG    lastD3;
  260. extern ULONG    lastD4;
  261. extern ULONG    lastD5;
  262. extern ULONG    lastD6;
  263. extern ULONG    lastD7;
  264. extern ULONG    lastA0;
  265. extern ULONG    lastA1;
  266. extern ULONG    lastA2;
  267. extern ULONG    lastA3;
  268. extern ULONG    lastA4;
  269. extern ULONG    lastA5;
  270. extern ULONG    lastA6;
  271. extern ULONG    lastA7;
  272.  
  273. enum DISPLAY_MODES {
  274.     DISPLAY_DISM,
  275.     DISPLAY_SOURCE,
  276.     DISPLAY_MIXED,
  277.     DISPLAY_BYTES,
  278.     DISPLAY_WORDS,
  279.     DISPLAY_LONGS,
  280.     DISPLAY_HUNKS,
  281.     DISPLAY_SYMBOL,
  282.     DISPLAY_HELP,
  283.     DISPLAY_BREAK,
  284.     DISPLAY_DOSBASE,
  285.     DISPLAY_PROCESS,
  286.     DISPLAY_INFO,
  287.     DISPLAY_EXECBASE,
  288.     DISPLAY_RESOURCES,
  289.     DISPLAY_INTRS,
  290.     DISPLAY_PORTS,
  291.     DISPLAY_TASKS,
  292.     DISPLAY_LIBS,
  293.     DISPLAY_DEVICES,
  294.     DISPLAY_MEMLIST,
  295.     DISPLAY_REXXLIST,
  296.     DISPLAY_SYMLIST,
  297.     MAX_MODES,
  298. };
  299.  
  300. #define MIXTYPE_DISM        1
  301. #define MIXTYPE_SOURCE        2
  302. #define MIXTYPE_NOSOURCE    3
  303.  
  304. extern DPREFS    dprefs;
  305.  
  306. extern char    commandLine[];
  307. extern UWORD    commandCol, commandEnd;
  308.  
  309. extern WP    wpTable[MAXWP];         // 32 user watchpoints
  310.  
  311. extern BP    bpTable[MAXBP];         // 32 user breakpoints
  312. extern BP    bpTemp;             // temporary breakpoint
  313. extern WORD    topBP;                // top breakpoint displayed from table
  314.  
  315. extern DBugDisp *CurDisplay;            //
  316.  
  317. extern unsigned long  ScrollStart, ScrollEnd;
  318. extern int SymbolCount;
  319.  
  320. // * Assembly Function Prototypes
  321.  
  322. Prototype __stkargs UBYTE    *MallocPublic(ULONG size);
  323. Prototype __stkargs UBYTE    *MallocFast(ULONG size);
  324. Prototype __stkargs UBYTE    *MallocChip(ULONG size);
  325. Prototype __stkargs UBYTE    *MallocAny(ULONG size, ULONG type);
  326. Prototype __stkargs void    Free(APTR ptr);
  327. Prototype __stkargs void    CleanMem(void);
  328. Prototype __stkargs ULONG    Disassemble(ULONG src, ULONG addr, char *buf);
  329. Prototype __stkargs void    EnterProgram(void);
  330. Prototype __stkargs void    TargetExit(void);
  331.  
  332. #define ID_SCROLL 0
  333. #define ID_UP    1
  334. #define ID_DOWN    2